package com.example.threaddemo;

import java.util.Random;

/**
 * 1. Serial 收集器  (DefNew  +  Tenured)
 *  -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseSerialGC
 * 2.  ParNew 收集器 (ParNew + Tenured)
 *  -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseParNewGC
 * 3.  ParNew 收集器 (PSYoungGen + ParOldGen)
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseParallelGC/+UseParallelOldGC
 * 4.  CMS 收集器 (PSYoungGen + ParOldGen)
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseConcMarkSweepGC
 *
 * 5.
 * -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseG1GC
 *
 * 6.  理论直到即可，实际jdk8已经优化掉，没有了
 *  -Xms10m -Xmx10m -XX:+PrintGCDetails -XX:+PrintCommandLineFlags -XX:+UseSerialOldGC
 */
public class GCDemo {
    public static void main(String[] args) {
        System.out.println("***********GCDemo hello****************");
        System.out.println();
        try {
            String str = "dota2";
            while (true){
                str += str + new Random().nextInt(777777777) + new Random().nextInt(99999999);
                str.intern();
            }
        }catch (Throwable e){
            e.printStackTrace();
        }
    }
}
